package com.yida.wy.basic.controller;

import com.mybatisflex.core.paginate.Page;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.wy.basic.domain.WyPropertyManagementCompanyScore;
import com.yida.wy.basic.service.IWyPropertyManagementCompanyScoreService;
import com.yida.wy.common.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

/**
 * 物业公司评分详情表 控制层。
 *
 * @author lqq
 * @since 1.0
 */
@RestController
@RequestMapping("/wyPropertyManagementCompanyScore")
@Api(tags = "物业公司评分详情表")
public class WyPropertyManagementCompanyScoreController extends BaseController {

    @Autowired
    private IWyPropertyManagementCompanyScoreService wyPropertyManagementCompanyScoreService;

    /**
     * 添加 物业公司评分详情表
     *
     * @param wyPropertyManagementCompanyScore 物业公司评分详情表
     * @return {@code true} 添加成功，{@code false} 添加失败
     */
    @PostMapping("/save")
    @ApiOperation(value = "添加物业公司评分详情表", notes = "添加物业公司评分详情表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "businessId", value = "业务主键"),
            @ApiImplicitParam(name = "propertyManagementCompanyId", value = "物业公司ID"),
            @ApiImplicitParam(name = "companyScoreId", value = "分数ID"),
            @ApiImplicitParam(name = "createYear", value = "创建年份"),
            @ApiImplicitParam(name = "createMonth", value = "创建月份"),
            @ApiImplicitParam(name = "approvalStatus", value = "审批状态:0未审批;1已审批"),
            @ApiImplicitParam(name = "approver", value = "审批人"),
            @ApiImplicitParam(name = "approvalTime", value = "审批时间"),
            @ApiImplicitParam(name = "approvalRemark", value = "审批意见")})
    public AjaxResult save(@RequestBody WyPropertyManagementCompanyScore wyPropertyManagementCompanyScore) {
        return toAjax(wyPropertyManagementCompanyScoreService.save(wyPropertyManagementCompanyScore));
    }


    /**
     * 根据主键删除物业公司评分详情表
     *
     * @param id 主键
     * @return {@code true} 删除成功，{@code false} 删除失败
     */
    @DeleteMapping("/remove/{id}")
    @ApiOperation(value = "根据主键删除物业公司评分详情表", notes = "根据主键删除物业公司评分详情表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "businessId", value = "业务主键", required = true)
    })
    public AjaxResult remove(@PathVariable Serializable id) {
        return toAjax(wyPropertyManagementCompanyScoreService.removeById(id));
    }


    /**
     * 根据主键更新物业公司评分详情表
     *
     * @param wyPropertyManagementCompanyScore 物业公司评分详情表
     * @return {@code true} 更新成功，{@code false} 更新失败
     */
    @PutMapping("/update")
    @ApiOperation(value = "根据主键更新物业公司评分详情表", notes = "根据主键更新物业公司评分详情表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "businessId", value = "业务主键", required = true),
            @ApiImplicitParam(name = "propertyManagementCompanyId", value = "物业公司ID"),
            @ApiImplicitParam(name = "companyScoreId", value = "分数ID"),
            @ApiImplicitParam(name = "createYear", value = "创建年份"),
            @ApiImplicitParam(name = "createMonth", value = "创建月份"),
            @ApiImplicitParam(name = "approvalStatus", value = "审批状态:0未审批;1已审批"),
            @ApiImplicitParam(name = "approver", value = "审批人"),
            @ApiImplicitParam(name = "approvalTime", value = "审批时间"),
            @ApiImplicitParam(name = "approvalRemark", value = "审批意见")})
    public AjaxResult update(@RequestBody WyPropertyManagementCompanyScore wyPropertyManagementCompanyScore) {
        return toAjax(wyPropertyManagementCompanyScoreService.updateById(wyPropertyManagementCompanyScore));
    }


    /**
     * 查询所有物业公司评分详情表
     *
     * @return 所有数据
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询所有物业公司评分详情表", notes = "查询所有物业公司评分详情表")
    public AjaxResult list() {
        return AjaxResult.success(wyPropertyManagementCompanyScoreService.list());
    }


    /**
     * 根据物业公司评分详情表主键获取详细信息。
     *
     * @param id wyPropertyManagementCompanyScore主键
     * @return 物业公司评分详情表详情
     */
    @GetMapping("/getInfo/{id}")
    @ApiOperation(value = "根据物业公司评分详情表主键获取详细信息", notes = "根据物业公司评分详情表主键获取详细信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "businessId", value = "业务主键", required = true)
    })
    public AjaxResult getInfo(@PathVariable Serializable id) {
        return AjaxResult.success(wyPropertyManagementCompanyScoreService.getById(id));
    }


    /**
     * 分页查询物业公司评分详情表
     *
     * @param page 分页对象
     * @return 分页对象
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询物业公司评分详情表", notes = "分页查询物业公司评分详情表")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页大小", required = true)
    })
    public TableDataInfo page(Page<WyPropertyManagementCompanyScore> page) {
        return getDataTable(wyPropertyManagementCompanyScoreService.page(page));
    }
}